﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BuildOptimizer
{
    class BoBuildOrder
    {
        private List<BoDecision> _decisions = new List<BoDecision>();

        public BoBuildOrder()
        {
        }
        public void addDecision(BoDecision decision)
        {
            _decisions.Add(decision);
        }
        public string toString()
        {
            StringBuilder builder = new StringBuilder();

            builder.AppendLine("Overview");
            builder.AppendLine("--------");
            builder.AppendLine("nbTicksPassed: " + nbTicksPassed);
            builder.AppendLine("minMinedTotal: " + mineralsMinedTotal);
            builder.AppendLine("gasMinedTotal: " + gasMinedTotal);
            builder.AppendLine();

            builder.AppendLine("Build Order");
            builder.AppendLine("-----------");

            for (int i = 0; i < _decisions.Count; i++)
            {
                builder.AppendLine(_decisions[i].toString());
            }

            return builder.ToString();
        }
        public int calcSimplicity()
        {
            int i = 0;
            bool found = false;
            
            for (i = 0; i < _decisions.Count && !found; i++)
            {
                bool isDrone = (_decisions[i].toString().IndexOf("-> Drone") != -1);
                bool isOverlord = (_decisions[i].toString().IndexOf("-> Overlord") != -1);
                found = (!isDrone && !isOverlord);
            }

            return i;
        }

        public float mineralsMinedTotal
        {
            get
            {
                return _decisions[_decisions.Count - 1].mineralsMinedTotal;
            }
        }
        public float gasMinedTotal
        {
            get
            {
                return _decisions[_decisions.Count - 1].gasMinedTotal;
            }
        }
        public int nbTicksPassed
        {
            get
            {
                return _decisions[_decisions.Count - 1].nbTicksPassed;
            }
        }
    }
}
